package com.book.controller;


import com.book.model.Menu;
import com.book.model.Operator;
import com.book.service.MenuService;
import com.book.service.OperatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wx
 * @since 2023-10-12 10:33:30
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private OperatorService operatorService;
    @Autowired
    private MenuService menuService;
    @GetMapping("ztreeGetMenuList")
    public List<Map<String,Object>> ztreeGetMenuList(HttpSession session){
        Operator operator = new Operator();
        operator.setOid(1l);
        //根据用户id查询菜单树
        session.setAttribute("user",operator);
       return operatorService.ztreeGetMenuList(session);

    }
    @PostMapping("addMenu")
    public void addMenu(Menu menu){
        menuService.addMenu(menu);
    }
    @PutMapping("updateMenu")
    public void updateMenu(Menu menu){
        menuService.updateMenu(menu);
    }
    @DeleteMapping("deleteMenu")
    public void deleteMenu(Long mid){
        menuService.deleteMenu(mid);
    }
}
